]> dgit.raspbian.org Git - gnome-shell.git/commit
init: Move Meta main loop into JavaScript after GJS context is initialized
authorEvan Welsh <contact@evanwelsh.com>
Wed, 7 Jun 2023 15:58:08 +0000 (08:58 -0700)
committerFlorian Müllner <fmuellner@gnome.org>
Wed, 7 Jun 2023 19:23:27 +0000 (19:23 +0000)
commit8fb8f7f827f56aa03a14d2012eed3cb6b1972ccd
tree604c6ac44e6d13f18817d169ca8063dd92ad272b
parent5d8e860a48e400f32700ea3824dce2f37bdcc704
init: Move Meta main loop into JavaScript after GJS context is initialized

gjs now has an internal mainloop that it can spin to resolve
module imports. That loop uses the thread default context,
so its possible that other sources, namely from mutter, get
dispatched when iterating the context. If that happens before
mutter is properly initialized, this will lead to a crash.

GjsContext needs to iterate its internal mainloop when initializing
to resolve internal modules, to avoid iterating Meta's mainloop and
triggering events before Meta is ready we will initialize the Shell
global and thus the GjsContext (js_context) before Meta.

Once GjsContext is initialized, we can call meta_context_setup().
Once Meta is setup and started, we'll run init.js which uses GJS'
internal promises API to set a "mainloop hook". The mainloop hook
is run immediately after the module returns so GJS will not attempt
to iterate the main loop again before exiting.

Also adjust the 'headlessStart' test to not wait for the
MetaContext::started signal, as that signal has now already
been emitted when the code is executed.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6691

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2781>
js/perf/headlessStart.js
js/ui/init.js
src/gnome-shell-plugin.c
src/main.c